home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Tools / Text / Edit / GoldED-Demo / installdata / golded / developer / syntax / include / scanlib.h
Encoding:
C/C++ Source or Header  |  1999-12-03  |  8.8 KB  |  203 lines

  1. #ifndef SCANLIB_H
  2. #define SCANLIB_H
  3.  
  4. /*
  5. **      $Filename: add-ons/developer/syntax/scanlib.h
  6. **      $Release:  6.2.3
  7. **
  8. **      Syntax parser definitions.
  9. **
  10. **      (C) Copyright 1999 Dietmar Eilert
  11. **          All Rights Reserved
  12. */
  13.  
  14. #ifndef MAKE_ID
  15. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  16. #endif
  17.  
  18. #define PARSER_MAGIC MAKE_ID('G','E','D','6')
  19.  
  20. /* library base */
  21.  
  22. struct ParserBase {
  23.  
  24.     struct Library Library;                          /* standard library */
  25.     UWORD          pad;                              /* we are now longword aligned */
  26.     ULONG          Magic;                            /* checked by editor to recognize syntax parsers */
  27. };
  28.  
  29. /* general description of parser properties (created by parser) */
  30.  
  31. struct ParserData {
  32.  
  33.     ULONG          pd_Release;                       /* version code of syntax parser interface */
  34.     ULONG          pd_Version;                       /* private release code of parser (optional) */
  35.     ULONG          pd_Serial;                        /* private serial code of parser  (optional) */
  36.     UBYTE         *pd_Info;                          /* short description */
  37.     UBYTE        **pd_Example;                       /* example text array or NULL */
  38.     UWORD          pd_Flags;                         /* flags (see below) */
  39.     ULONG          pd_Properties;                    /* configurability flags for generic configuration interface (see below) */
  40.     APTR           pd_Reserved;                      /* reserved */
  41.  
  42.     /* private data of syntax parser may follow */
  43. };
  44.  
  45. /* syntax parsing interface version supported by parser (ParserData->pd_Release) */
  46.  
  47. #define SCANLIBVERSION 6
  48.  
  49. /* flags (ParserData->pd_Flags) */
  50.  
  51. #define SCPRB_CONFIGWIN              1L              /* syntax parser has its own configuration window */
  52. #define SCPRF_CONFIGWIN              (1L<<1)
  53.  
  54. #define SCPRB_SYNTAXCACHE            2L              /* syntax cache supported */
  55. #define SCPRF_SYNTAXCACHE            (1L<<2)
  56.  
  57. #define SCPRB_CONTEXT                3L              /* context parsing supported */
  58. #define SCPRF_CONTEXT                (1L<<3)
  59.  
  60. #define SCPRB_GENERIC                4L              /* generic configuration interface supported */
  61. #define SCPRF_GENERIC                (1L<<4)
  62.  
  63. /* configurable properties (ParserData->pd_Properties) */
  64.  
  65. #define SCPRB_DICTIONARY             1L              /* parser supports dictionary */
  66. #define SCPRF_DICTIONARY             (1L<<1)
  67.  
  68. #define SCPRB_CASESENSITIVITY        2L              /* parser supports case-sensitivity */
  69. #define SCPRF_CASESENSITIVITY        (1L<<2)
  70.  
  71. #define SCPRB_COMMENTS               3L              /* parser supports comments (normal comments) */
  72. #define SCPRF_COMMENTS               (1L<<3)
  73.  
  74. #define SCPRB_COMMENTLINES           4L              /* parser supports comments (comments until end of line) */
  75. #define SCPRF_COMMENTLINES           (1L<<4)
  76.  
  77. #define SCPRB_COMMENTNESTING         5L              /* parser supports nested comments */
  78. #define SCPRF_COMMENTNESTING         (1L<<5)
  79.  
  80. #define SCPRB_STRINGS                6L              /* parser supports strings */
  81. #define SCPRF_STRINGS                (1L<<6)
  82.  
  83. #define SCPRB_STRINGESC              7L              /* parser supports string esc sequence */
  84. #define SCPRF_STRINGESC              (1L<<7)
  85.  
  86. #define SCPRB_LITERALS               8L              /* parser supports literals */
  87. #define SCPRF_LITERALS               (1L<<8)
  88.  
  89. #define SCPRB_LITERALESC             9L              /* parser supports literal esc sequence */
  90. #define SCPRF_LITERALESC             (1L<<9)
  91.  
  92. #define SCPRB_BLOCKS                 10L             /* parser supports blocks */
  93. #define SCPRF_BLOCKS                 (1L<<10)
  94.  
  95. #define SCPRB_BLOCKNESTING           11L             /* parser supports nested blocks */
  96. #define SCPRF_BLOCKNESTING           (1L<<11)
  97.  
  98. #define SCPRB_PREFIXBIN              12L             /* parser supports bin prefix */
  99. #define SCPRF_PREFIXBIN              (1L<<12)
  100.  
  101. #define SCPRB_PREFIXOCT              13L             /* parser supports oct prefix */
  102. #define SCPRF_PREFIXOCT              (1L<<13)
  103.  
  104. #define SCPRB_PREFIXHEX              14L             /* parser supports hex prefix */
  105. #define SCPRF_PREFIXHEX              (1L<<14)
  106.  
  107. #define SCPRB_WHITESPACE             15L             /* parser supports whitespace definition */
  108. #define SCPRF_WHITESPACE             (1L<<15)
  109.  
  110. #define SCPRB_COMMENTALT             16L             /* parser supports alternative comment */
  111. #define SCPRF_COMMENTALT             (1L<<16)
  112.  
  113. /* parser handle (created by parser) */
  114.  
  115. struct ParserHandle {
  116.  
  117.     UWORD          ph_Levels;                        /* number of syntax levels understood by parser */
  118.     UBYTE        **ph_Names;                         /* array of level names (0-terminated) */
  119.     ULONG         *ph_ColorsFG;                      /* suggested colors (BGR, see below) */
  120.     ULONG         *ph_ColorsBG;                      /* suggested colors (BGR, see below) */
  121.     APTR           ph_Reserved;                      /* reserved */
  122.  
  123.     /* private data of syntax parser may follow */
  124. };
  125.  
  126. /* data format of color table 00bbggrr (ParserHandle->ph_ColorsFG/BG) */
  127.  
  128. #define MAKE_BGR8(b,g,r) ((ULONG)(((ULONG)b) & 255)<<16 | (ULONG)(((ULONG)g) & 255)<<8 | (ULONG)((ULONG)(r) & 255))
  129.  
  130. /* syntax chunk (the parser returns an 0-terminated array of this structure to the editor) */
  131.  
  132. struct SyntaxChunk {
  133.  
  134.     UWORD          sc_Start;                         /* column: segment start */
  135.     UWORD          sc_End;                           /* column: segment end */
  136.     UWORD          sc_Level;                         /* syntax level of this segment */
  137. };
  138.  
  139. /* syntax parser notification message (sent from editor to syntax parser) */
  140.  
  141. struct ScannerNotify {
  142.  
  143.     ULONG          sn_Class;                         /* action class */
  144.     ULONG          sn_Code;                          /* action code */
  145.     ULONG          sn_Line;                          /* line of operation */
  146.     LONG           sn_Lines;                         /* lines affected by operation */
  147.     LONG           sn_Removed;                       /* lines removed during operation */
  148.     APTR           sn_Reserved;                      /* reserved (set to NULL) */
  149. };
  150.  
  151. /* notification classes (ScannerNotify->sn_Class) */
  152.  
  153. #define SCANNER_NOTIFY_MODIFIED 1L                   /* lines have been inserted, deleted or modified */
  154.  
  155. /* display refresh request (created by syntax parser to request an additional display refresh) ) */
  156.  
  157. struct RefreshRequest {
  158.  
  159.     ULONG           rr_Line;                         /* first line to be refreshed */
  160.     ULONG           rr_Lines;                        /* lines to be refreshed */
  161. };
  162.  
  163. /* setup information (created by editor) */
  164.  
  165. struct SyntaxSetup {
  166.  
  167.     struct List    *sp_Categories;                   /* dictionary categories (or NULL) */
  168.     struct Entry   *sp_Dictionary;                   /* dictionary, sorted and 0-terminated (or NULL) */
  169.     BOOL            sp_CaseSensitive;                /* case-sensitive dictionary ? */
  170.     UBYTE          *sp_CommentStart;                 /* comment delimiter (or NULL) */
  171.     UBYTE          *sp_CommentEnd;                   /* comment delimiter (or NULL) */
  172.     UBYTE          *sp_CommentLine;                  /* comment delimiter (or NULL) */
  173.     BOOL            sp_CommentNesting;               /* comment nesting ? */
  174.     UBYTE          *sp_BlockStart;                   /* block delimiter (or NULL) */
  175.     UBYTE          *sp_BlockEnd;                     /* block delimiter (or NULL) */
  176.     BOOL            sp_BlockNesting;                 /* block nesting ? */
  177.     BOOL            sp_WhiteSpace[256];              /* white-space definition array */
  178.     UBYTE          *sp_PrefixBin;                    /* number prefix (or NULL) */
  179.     UBYTE          *sp_PrefixOct;                    /* number prefix (or NULL) */
  180.     UBYTE          *sp_PrefixHex;                    /* number prefix (or NULL) */
  181.     UBYTE          *sp_String;                       /* string delimiter (or NULL) */
  182.     UBYTE          *sp_StringESC;                    /* string escape sequence (or NULL) */
  183.     UBYTE          *sp_Literal;                      /* literal delimiter (or NULL) */
  184.     UBYTE          *sp_LiteralESC;                   /* literal escape sequence (or NULL) */
  185.     UBYTE          *sp_Arguments;                    /* other arguments (or NULL) */
  186.     UBYTE          *sp_CommentAlt;                   /* alternative comment delimiter (or NULL) */
  187. };
  188.  
  189. /* dictionary entry; this is a VARIABLE-SIZED STRUCTURE (word-aligned via pad-bytes) ! */
  190.  
  191. struct Entry {
  192.  
  193.     UWORD           en_Length;                       /* keyword length */
  194.     UWORD           en_Category;                     /* keyword category (ID in bit 0-7) */
  195.     UBYTE           en_Text[1];                      /* 0-terminated string follows */
  196. };
  197.  
  198. /* minimum size of the previous structure */
  199.  
  200. #define SIZEOF_STRUCT_ENTRY (sizeof(UWORD) + sizeof(UWORD))
  201.  
  202. #endif
  203.